package com.jsgt.greekfire.repository

import com.jsgt.greekfire.bean.PoolBean
import com.jsgt.greekfire.bean.PoolOrderBean
import com.jsgt.greekfire.bean.PrivilegeBean
import com.jsgt.greekfire.bean.PrivilegeWalletBean
import com.jsgt.greekfire.common.http.ResponseData
import com.jsgt.greekfire.common.http.ResultData
import com.jsgt.greekfire.common.http.RetrofitManager
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext

class PrivilegeRepository : BaseRepository() {
    companion object {
        val instance = PrivilegeRepository()
    }

    /**
     * 云创智/云创联 -特权收益
     * type 0-云创智 1-云创联
     */
    suspend fun getPrivilege(type: Int): ResponseData<List<PrivilegeBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.getPrivilege(type)
        }

    /**
     * 云矿池列表
     */
    suspend fun poolList(): ResponseData<List<PoolBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.poolList()
        }

    /**
     * 云创智/云创联 -钱包
     * type 0-云创智 1-云创联
     */
    suspend fun getPrivilegeWallet(type: Int): ResponseData<List<PrivilegeWalletBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.getPrivilegeWallet(type)
        }

    /**
     * 云创智/云创联 -划转
     */
    suspend fun privilegeWalletTransfer(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.privilegeWalletTransfer(parseBody(params))
        }


    /**
     * 转入云矿池/云矿场
     */
    suspend fun poolIn(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.poolIn(parseBody(params))
        }


    /**
     * 转出云矿池/云矿场
     */
    suspend fun poolOut(params: Map<String, Any>): ResponseData<Any> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.poolOut(parseBody(params))
        }

    /**
     * 获取池订单列表
     */
    suspend fun poolOrderList(type: String): ResponseData<ResultData<PoolOrderBean>> =
        withContext(Dispatchers.IO) {
            RetrofitManager.privilegeService.poolOrderList(type)
        }
}